// ==UserScript==
// @name         塔防精灵每日礼包-自动领取
// @namespace    http://VIPArcher.orz/
// @version      v1.1
// @description  在路径后面添加?key=授权码。例如：http://101.132.194.116:9001/?key=5A4ABA******1E9C11，访问后自动操作
// @author       VIPArcher
// @match        *://101.132.194.116/*
// @icon         https://www.tangu11g.com/img/game-choice-icon-1.png
// @grant unsafeWindow
// @require http://101.132.194.116:9001/塔防精灵_广告_直播_游戏_files/jquery-3.3.1.min.js
// ==/UserScript==

(function() {
    'use strict';
    $(function() {
        setTimeout(() => {
            $("#tipModalCenter").hide()
            $('.modal-backdrop').hide()
            let type = getUrlParam("type")
            if (type) {
                $(`input[name="type"][value="${type}"]`).prop('checked', true);
            }
            let key = getUrlParam("key")
            if (key) {
                $('#check_code').val(key)
                btnBegin()
            }
        }, 200)
    })

    // 获取URL参数
    function getUrlParam(name) {
        const regExp = new RegExp(`[?&]${name}=([^&#]*)`);
        const results = regExp.exec(window.location.search);
        return results === null ? null : decodeURIComponent(results[1].replace(/\+/g, ' '));
    }
})();